﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WumpusTest
{
    public class Entity
    {
        public Planet CurrentPlanet;

        public Entity(ref Planet currentPlanet)
        {
            this.CurrentPlanet = currentPlanet;
        }

        public void VisitsPlanet(Planet planet)
        {

        }
    }

    public class Hazard : Entity
    {
        public Hazard(ref Planet currentPlanet) :
            base(ref currentPlanet)
        {
            // Empty
        }

        public void ChangeLocationRandomly()
        {
            List<Planet> neighbors = this.CurrentPlanet.Neighbors;
            int index = random.Next(neighbors.Count);
            this.CurrentPlanet = neighbors[index];
        }

        protected static Random random = new Random();
    }
    
    public class Player : Entity
    {
        public Player(ref Planet currentPlanet) :
            base(ref currentPlanet)
        {
            arrows = 3;
            goldCoins = 0;
            score = 0;
            turnsTaken = 0;

            VisitsPlanet(currentPlanet);
            foreach(Planet planet in currentPlanet.Neighbors){
                VisitsPlanet(planet);
            }
        }

        /// <summary>
        /// Updates player data when it encounters a Wumpus.
        /// </summary>
        public void FindsWumpus()
        {
            arrows = arrows - 1;
            turnsTaken = turnsTaken + 1;
        }

        public bool IsOutOfArrows()
        {
            if (arrows == 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }

        public void FindsBats()
        {
            turnsTaken = turnsTaken + 1;
        }

        public void FindsHole()
        {
            turnsTaken = turnsTaken + 1;
        }

        public int arrows;
        public int goldCoins;
        public int score;
        public int turnsTaken;

        protected List<Planet> visitedPlanets;
    }

    public class Bat : Hazard
    {
        public Bat(ref Planet currentPlanet) :
            base(ref currentPlanet)
        {
            // Empty
        }
    }

    public class Wumpus : Hazard
    {
        public Wumpus(ref Planet currentPlanet) :
            base(ref currentPlanet)
        {
            // Empty
        }
    }

}
